package com.neuedu.studentmanage.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.neuedu.studentmanage.entity.Pager;
import com.neuedu.studentmanage.entity.Result;
import com.neuedu.studentmanage.entity.Spends;
import com.neuedu.studentmanage.mapper.SpendsMapper;
import com.neuedu.studentmanage.service.SpendsService;

@Service
@Transactional
public class SpendsServiceImpl implements SpendsService{
	
	@Autowired  //自动装配
	private SpendsMapper spendsMapper;
	
	@Override
	public List<Spends> findAll() {
		return spendsMapper.findAll();
	}

	@Override
	public List<Spends> findListByPager(Pager<Spends> pager) {
		return spendsMapper.findListByPager(pager);
	}

	@Override
	public Integer findTotalByPager(Pager<Spends> pager) {
		return spendsMapper.findTotalByPager(pager);
	}

	@Override
	public Result add(Spends spends) {
		Result result= new Result(false,"新增消费失败");
		boolean res= spendsMapper.add(spends);
		if(res) {
			result= new Result(true,"新增消费成功");
		}
		return result;
	}

	@Override
	public Result edit(Spends spends) {
		Result result = new Result(false,"修改消费失败");
		boolean res=spendsMapper.edit(spends);
		if(res) {
			result=new Result(true,"修改消费成功");
		}
		return result;
	}

	@Override
	public Result deleteByIds(List<Spends> ids) {
		Result result = new Result(false,"删除消费失败");
		boolean res= spendsMapper.deleteByIds(ids);
		if(res) {
			result= new Result(true,"删除消费成功");
		}
		return result;
	}

	

}
